{extend name="layout" /}
{block name="body"}
<div class="row">
    <div class="col-lg-12">
        <div class="card">
            <div class="card-body">
                <div class="form-group">
                    <input type="hidden" id="id" value="{if $type == 1}{$data.id}{/if}">
                    <label for="title">标题</label>
                    <input type="text" class="form-control" id="title" value="{if $type == 1}{$data.title}{/if}" placeholder="请输入标题">
                </div>
                <div class="form-group">
                    <label for="content">内容</label>
                    <textarea class="form-control" id="content" rows="3"
                        placeholder="内容">{if $type == 1} {$data.content}{/if}</textarea>
                </div>
                <div class="form-group">
                    <label for="icon">icon</label>
                    <input type="text" class="form-control" id="icon" value="{if $type == 1}{$data.icon}{/if}" placeholder="icon">
                </div>
                <div class="form-group">
                    <label for="satus">状态</label>
                    <input type="number" class="form-control" id="satus" value="{if $type == 1}{$data.satus}{/if}" placeholder="请输入状态">
                </div>
                <div class="form-group">
                    <label for="appid">appid</label>
                    <input type="number" class="form-control" id="appid" value="{if $type == 1}{$data.appid}{/if}" placeholder="请输入appid">
                </div>
                <div class="form-group">
                    <label for="userid">userid</label>
                    <input type="number" class="form-control" id="userid" value="{if $type == 1}{$data.userid}{/if}" placeholder="请输入userid">
                </div>
                <button type="buttons" onclick="update()" class="btn btn-w-sm btn-primary mb-2">提交</button>
                <button type="button" class="btn btn-default mb-2" onclick="javascript:history.back(-1);return false;">返
                    回
                </button>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="js"}
<script>
    function update() {
        var l = $('body').lyearloading({
            opacity: 0.2,
            spinnerSize: 'lg',
            spinnerText: '后台处理中，请稍后...',
            textColorClass: 'text-info',
            spinnerColorClass: 'text-info'
        });
        var id = $.trim($("#id").val());
        var title = $.trim($("#title").val());
        var content = $.trim($("#content").val());
        var icon = $.trim($("#icon").val());
        var satus = $.trim($("#satus").val());
        var appid = $.trim($("#appid").val());
        var userid = $.trim($("#userid").val());
        $.ajax({
            type: "POST",
            url: "{:url('expand/edit_do')}",
            data: {
                id: id,
                title: title,
                content: content,
                icon: icon,
                satus: satus,
                appid: appid,
                userid: userid,
            },
            dataType: "json",
            success: function (data) {
                setTimeout(function () {
                    l.destroy();
                }, 1e3)
                if (data.code == 1) {
                    if(id == ""){
                        notify.success(data.msg,function () {
                            location.href = data.url;
                        },3000);
                    }else{
                        notify.success(data.msg);
                    }
                } else {
                    notify.error(data.msg);
                }
            },
            error: function () {
                l.destroy();
                notify.error("系统错误");
            }
        })
    }

</script>
{/block}